package com.fz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fz.entity.PageView;
import com.fz.mapper.PageViewMapper;
import com.fz.service.PageViewService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 存储用户与公告关联信息 服务实现类
 * </p>
 *
 * @author hyr
 * @since 2025-06-18
 */
@Service
public class PageViewServiceImpl extends ServiceImpl<PageViewMapper, PageView> implements PageViewService {
    @Override
    public Boolean view(Long id,Integer status,Integer statu){return this.updateById(new PageView(id,status,statu));}
    @Override
    public Boolean add(Long userId, Long noticeId) {
        PageView tPageview=new PageView(userId,noticeId,1);

        return this.save(tPageview);
    }
    @Override
    public  Boolean panduan(Long userId, Long noticeId){
        QueryWrapper<PageView> wrapper=new QueryWrapper<>();
        wrapper.eq("user_id",userId)
                .eq("notice_id",noticeId);
        return this.count(wrapper)==0;

    }
}
